/** File: 	MainWindow.java
 *  Author:	Christopher Hayes
 *	Date:	Oct 15, 2009
 * 	Class:  CMSC 345
 * 
 */
package cx3k.GUI;


import java.awt.*;

import javax.swing.*;

/**
 * @author chris
 *
 */
public class MainWindow extends JFrame {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	public static final Color MAINCOLOR = new Color(251, 210, 0);
	
	private ProfilePane profile;
	private SchedulePane schedule;
	private ClassInfo classInfo;
	private SearchPane search;
	private Scheduler scheduler;

	public MainWindow () {
		this.setTitle("Cx3K Scheduler");
		this.setDefaultCloseOperation(EXIT_ON_CLOSE);
		this.setSize(1000, 700);
		this.setResizable(false);
		GridBagLayout gbl = new GridBagLayout();
		this.setLayout(gbl);
		GridBagConstraints gbc = new GridBagConstraints();
		this.scheduler = new Scheduler();
		this.setJMenuBar(new MyMenuBar(scheduler));
		
		
		//Create Profile and add it to frame
		profile = new ProfilePane(scheduler);
		gbc.gridx = 0;
		gbc.gridy = 0; 
		gbc.gridwidth = 1; 
		gbc.gridheight = 1; 
		gbc.weightx = 45; 
		gbc.weighty = 60; 
		gbc.fill = GridBagConstraints.BOTH; 
		gbc.anchor = GridBagConstraints.LINE_START; 
		gbl.setConstraints(profile, gbc);
		this.add(profile); 
		
		//Create Schedule and add it to frame
		schedule = new SchedulePane(scheduler);
		gbc.gridx = 0;
		gbc.gridy = 1; 
		gbc.gridwidth = 3; 
		gbc.gridheight = 1; 
		gbc.weightx = 85; 
		gbc.weighty = 40; 
		gbl.setConstraints(schedule, gbc);
		this.add(schedule); 
		
		//Create ClassInfo and add it to frame
		classInfo = new ClassInfo();
		gbc.gridx = 2;
		gbc.gridy = 0; 
		gbc.gridwidth = 1; 
		gbc.gridheight = 1; 
		gbc.weightx = 40; 
		gbc.weighty = 60; 
		gbl.setConstraints(classInfo, gbc);
		this.add(classInfo); 
		
		//Create Search and add it to frame
		search = new SearchPane();
		gbc.gridx = 3;
		gbc.gridy = 0; 
		gbc.gridwidth = 1; 
		gbc.gridheight = 2; 
		gbc.weightx = 15; 
		gbc.weighty = 100; 
		gbl.setConstraints(search, gbc);
		this.add(search); 
		
		//Center frame on screen
		Toolkit toolkit = this.getToolkit();
	    Dimension size = toolkit.getScreenSize();
	    this.setLocation(size.width/2 - getWidth()/2, size.height/2 - getHeight()/2);

		this.setVisible(true);
	}
	
	
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		MainWindow m = new MainWindow();
		m.toString();
	}

}
